class_name GameplayTagManager
## Gameplay Tag Manager
## Version: 0.1.0

##
signal tag_added(tag: String)

##
signal tag_removed(tag: String)

##
var tags: Array[String] = []


#region Add
func add_tag(new_tag: String) -> void:
	if not tags.has(new_tag):
		tags.append(new_tag)

		tag_added.emit(new_tag)


func add_tags(new_tags: Array[String]) -> void:
	for new_tag: String in new_tags:
		add_tag(new_tag)
#endregion


#region Delete
func remove_tag(removed_tag: String) -> void:
	for tag: String in tags:
		if tag.begins_with(removed_tag):
			tags.erase(tag)
			
			tag_removed.emit(removed_tag)


func remove_tags(removed_tags: Array[String]) -> void:
	for tag: String in removed_tags:
		remove_tag(tag)
#endregion


#region Find
func has_tag(target_tag: String) -> bool:
	for tag: String in tags:
		if tag.begins_with(target_tag):
			return true
	return false


func has_any_tags(target_tags: Array[String]) -> bool:
	for tag: String in target_tags:
		if has_tag(tag):
			return true
	return false


func has_all_tags(target_tags: Array[String]) -> bool:
	for tag: String in target_tags:
		if not has_tag(tag):
			return false
	return true


func get_all_tags() -> Array[String]:
	return tags
#endregion
